package server.content.skills.fm;

import java.util.LinkedList;
import java.util.List;

public class GlobalFireHandler {

	private static final List<GlobalFire> fires = new LinkedList<GlobalFire>();

	public GlobalFireHandler() {

	}

	public boolean addFire(final GlobalFire fire) {
		if (fire == null) {
			return false;
		}
		if (!fires.contains(fire)) {
			fires.add(fire);
			return true;
		}
		return false;
	}

	public boolean fireExists(final int x, final int y) {
		for (final GlobalFire fire : fires) {
			if (fire == null || fire.isDead())
				continue;
			if (fire.getX() == x && fire.getY() == y) {
				return true;
			}
		}
		return false;
	}
	
	public void process() {
		for (final GlobalFire fire : fires) {
			if (fire == null)
				continue;
			if (fire.isDead())
				continue;
			fire.processFire();
		}
	}
}
